#ifndef LEXER_H
#define LEXER_H

#include "token.h"
#include "location.h"
#include <stdio.h>

typedef struct _lexer{
        char *buffer;
        int size;
        int pos;
        char ch;
        int hasComment;
		int column;
        SourceLocation location;
}Lexer;

Lexer *createLexer();
Lexer *initLexer(Lexer *lexer,char *buffer,int size);
Lexer *initLexerByFile(Lexer *lexer,FILE *fl);

Token *readToken(Lexer *lexer);
Token *readNKToken(Lexer *self);

void printLexerError(Lexer *lexer,char *text,Token *token);

Token *readCommentLine(Lexer *lexer);
Token *readCommentBlock(Lexer *lexer);
Token *readFloat(Lexer *lexer,Token *token,int len);
Token *readString(Lexer *lexer);
Token *readStringSingle(Lexer *lexer); //单引号的解析

Token *readLexerToken(Lexer *lexer);
Token *readIdentify(Lexer *lexer);
Token *readNumber(Lexer *lexer);
Token *readOptToken(Lexer *lexer);
int readChar(Lexer *lexer);


int isDigit(char c);
int isDigitOct(char c);
int isDigitHex(char c);
int isLetter(char c);
int isLetterOrDigit(char c);
int isSkip(char c);
int isNewLine(char c);

#endif // LEXER_H
